
#ifndef _KRAW_DISPLAY_H_
#define _KRAW_DISPLAY_H_

namespace Kraw
{
/// Graphics classes

class MeshSource;
class Display;

class Mesh
{
public:
    Mesh(Display* display) :
        pDisplay(display)
    {}
    Display* pDisplay;
};

class DisplayMode
{
public:
    enum Type
    {
        Windowed,       // windowed mode
        Fullscreen,     // fullscreen mode
        AlwaysOnTop,    // windowed, always on top
        ChildWindow,    // windowed, as child window
    };

    enum Bpp
    {
        Bpp16,
        Bpp32,
    };

    DisplayMode();
    DisplayMode(Type t, ushort x, ushort y, ushort w, ushort h, bool vSync, bool dialogBoxMode);
    void Set(Type t, ushort x, ushort y, ushort w, ushort h, bool vSync, bool dialogBoxMode);

    Type type;
    ushort xpos;
    ushort ypos;
    ushort width;
    ushort height;
    Bpp bitsPerPixel;

    bool verticalSync;
    bool dialogBoxMode;
};

class Display
{
public:
    enum TransformType
    {
        World = 0,
        View,
        Projection,
        InvWorld,
        InvView,
        WorldView,
        WorldViewProjection,
        WorldLight,
        InvWorldLight,
        WorldLightProjection,
        ShadowProjection,

        Max_TransformTypes,
    };

    enum BufferType
    {
        NoBuffer  = 0,
        ColorBuffer = (1<<0),
        DepthBuffer = (1<<1),
        StencilBuffer = (1<<2),
        AllBuffers = (ColorBuffer|DepthBuffer|StencilBuffer),
    };

    enum PrimitiveType
    {
        PointList,
        LineList,
        LineStrip,
        TriangleList,
        TriangleStrip,
        TriangleFan,
    };

    enum IndexType
    {
        Index16,
        Index32,
    };

	static Display* Create();
	Display();
	~Display();

	bool Open();
	void Close();

	bool Update();
	bool BeginDraw();
	void EndDraw();

    void Clear(int bufferTypes, float red, float green, float blue, float alpha, float z, int stencil);

    //transforms
    void SetTransform( TransformType type, const matrix44& mat );
	const matrix44& GetTransform( TransformType type );
    
    //geometry and rendering
	Mesh* LoadMesh( MeshSource* mesh );
	bool DrawMesh( Mesh* mesh );
	
	//draw stuff on the screen
	void TestDraw();
	//void DrawText();

    int width;
    int height;
    int left;
    int top;

    bool bFullscreen;
    bool bVerticalSync;
	bool bIsOpen;
    bool bIsQuitRequested;

    //BEGIN- Humus
    int colorBits;
    int depthBits;
    int stencilBits;

    int antiAliasSamples;

    int screenIndex;
    //END- Humus
};

} //namespace Kraw

#endif //_KRAW_DISPLAY_H_
